From a9afd43e3b900aff9e4730f03ce8f5500e83fdb9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Wed, 22 Feb 2006 12:58:25 +0000 Subject: [PATCH] added gggl backing conversions --- ChangeLog | 5 ++++ extensions/gggl.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e26caf1..f256752 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-02-22 Øyvind Kolås + + * extensions/gggl.c: (conv_rgbaF_rgb8), (conv_rgbAF_rgbF), (init): + added two more conversions for gggl usage. + 2005-12-17 Michael Schumacher * extensions/Makefile.in: add libgw32 and its dependencies to diff --git a/extensions/gggl.c b/extensions/gggl.c index e26ab72..bf3fe83 100644 --- a/extensions/gggl.c +++ b/extensions/gggl.c @@ -49,7 +49,7 @@ * gamma correction (not really,. gamma correction belongs in seperate ops,. */ -//#define USE_TABLES +#define USE_TABLES #ifdef USE_TABLES /* lookup tables used in conversion */ @@ -337,6 +337,34 @@ conv_8_16 (unsigned char *src, unsigned char *dst, long samples) return samples; } +static INLINE long +conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples) +{ + long n=samples; + while (n--) + { + register float f = (*(float *) src); + *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)]; + src += 4; + dst += 1; + + f = (*(float *) src); + *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)]; + src += 4; + dst += 1; + + f = (*(float *) src); + *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)]; + src += 4; + dst += 1; + + src += 4; + + } + return samples; +} + + /*********/ static INLINE long conv_rgbaF_rgba8 (unsigned char *src, unsigned char *dst, long samples) @@ -581,6 +609,49 @@ conv_rgbAF_rgbaF (unsigned char *src, unsigned char *dst, long samples) return samples; } + +static INLINE long +conv_rgbAF_rgbF (unsigned char *src, unsigned char *dst, long samples) +{ + long n=samples; + while (n--) + { + float alpha = (((float *) src)[3]); + if (alpha >= 1.0) + { + register int c; + for (c = 0; c < 3; c++) + { + *(float *) dst = *(float *) src; + dst += 4; + src += 4; + } + } + else if (alpha <= 0.0) + { + register int c; + for (c = 0; c < 3; c++) + { + *(float *) dst = 0; + dst += 4; + src += 4; + } + } + else + { + register int c; + for (c = 0; c < 3; c++) + { + *(float *) dst = ((*(float *) src) / alpha); + dst += 4; + src += 4; + } + } + src += 4; + } + return samples; +} + static INLINE long conv_rgbaF_rgbAF (unsigned char *src, unsigned char *dst, long samples) { @@ -2014,6 +2085,8 @@ init (void) o (rgbaF, yuvaF); o (rgbaF, rgbaD); o (rgbaD, rgbaF); + o (rgbaF, rgb8); + o (rgbAF, rgbF); #if 0 o (rgbF, xyzF); o (xyzF, rgbF); -- 2.30.2